<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div1{background: red;width: 105px;height: 100px}
        #div2{background: green;width: 105px;height: 100px}
    </style>
    <script>
        window.onload=function (){
            document.getElementById("button1").addEventListener("click",function (){
                document.getElementById("div1").style.backgroundColor='red';
                document.getElementById("div2").style.backgroundColor='white';
            });
            document.getElementById("button2").addEventListener("click",function (){
                document.getElementById("div1").style.backgroundColor='white';
                document.getElementById("div2").style.backgroundColor='green';
            });
        }
    </script>
</head>
<body>
<input type="button" value="按钮1" id="button1">
<input type="button" value="按钮2" id="button2">
<div>
    <div id="div1"></div>
    <div id="div2"></div>
</div>
</body>
</html>